<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>租借情况</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <style>
        .top {
            float: right;
            position: relative;
            top: -25px;
            background-color: rgb(39, 39, 112);
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">租借情况</h3>
                <a href="admin_main.html"><button class="btn btn-primary top">返回信息管理界面</button></a>
                <a href="sell.html"><button class="btn btn-primary top">查看出售情况</button></a>
            </div>
        </div>

        <table class="table table-bordered table-hover table-striped">
            <thead>
                <tr>
                    <th>编号</th>
                    <th>租借用户名</th>
                    <th>商品名称</th>
                    <th>价格</th>
                    <th>租借数量</th>
                    <th>租借天数</th>
                </tr>
            </thead>
            <tbody>
                <tr v-for="item in list" :key="item.id">
                    <td> {{item.id}} </td>
                    <td> {{item.username}} </td>
                    <td> {{item.goodname}} </td>
                    <td> {{item.goodprice}}元/天</td>
                    <td> {{item.number}} </td>
                    <td> {{item.day}}天 </td>
                    <span> 总价: {{zprice}} 元 </span>
                </tr>
            </tbody>
            <span> 已租借总数: {{list.length}} </span>
            &nbsp;&nbsp;&nbsp;&nbsp;
        </table>
    </div>
</body>
<script src="js/vue.js"></script>
<script src="js/vue-resource.min.js"></script>
<script>
    Vue.http.options.emulateJSON = true;

    var vm = new Vue({
        el: "#app",
        data: {
            list: [],
            zprice: '',
        },
        created() {
            this.getAllList();
        },
        methods: {
            getAllList: function () {
                this.$http.get('php/sel.php').then(function (result) {
                    this.list = result.body;
                    // this.zprice = result.body[1][day];
                    for (var i = 0; i < this.list.length; i++) {
                        jiage = parseFloat(result.body[i].goodprice * result.body[i].number * result
                            .body[i]
                            .day);
                        var zongjia = 0;
                        zongjia += jiage;
                        this.zprice = zongjia;
                    }
                    console.log(this.zprice);
                })
            }
        }
    })
</script>

</html>